package com.ruoyi.web.controller.laiqianba.product;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.laiqianba.enums.ChargeTypeEnum;
import com.ruoyi.laiqianba.enums.PostInfoEnum;
import com.ruoyi.laiqianba.enums.UnionStatusEnum;
import com.ruoyi.product.service.IProductBaseInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.ProductUnionResultInfo;
import com.ruoyi.product.service.IProductUnionResultInfoService;
import com.ruoyi.web.wrapper.ProductUnionResultInfoWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品联登结果信息Controller
 * 
 * @author ruoyi
 * @date 2023-12-11
 */
@RestController
@RequestMapping("/product/productUnion")
public class ProductUnionResultInfoController extends BaseController
{
    @Autowired
    private IProductUnionResultInfoService productUnionResultInfoService;

    /**
     * 查询产品联登结果信息列表
     */
    @PreAuthorize("@ss.hasPermi('product:productUnion:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProductUnionResultInfo productUnionResultInfo)
    {
        startPage();
        List<Map<String, Object>> list = productUnionResultInfoService.selectProductUnionResultInfoMapList(productUnionResultInfo);
        list = new ProductUnionResultInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出产品联登结果信息列表
     */
    @PreAuthorize("@ss.hasPermi('product:productUnion:export')")
    @Log(title = "产品联登结果信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductUnionResultInfo productUnionResultInfo)
    {
        List<ProductUnionResultInfo> list = productUnionResultInfoService.selectProductUnionResultInfoList(productUnionResultInfo);
        ExcelUtil<ProductUnionResultInfo> util = new ExcelUtil<ProductUnionResultInfo>(ProductUnionResultInfo.class);
        util.exportExcel(response, list, "产品联登结果信息数据");
    }

    /**
     * 获取产品联登结果信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('product:productUnion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(productUnionResultInfoService.selectProductUnionResultInfoById(id));
    }

    /**
     * 新增产品联登结果信息
     */
    @PreAuthorize("@ss.hasPermi('product:productUnion:add')")
    @Log(title = "产品联登结果信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductUnionResultInfo productUnionResultInfo)
    {
        return toAjax(productUnionResultInfoService.insertProductUnionResultInfo(productUnionResultInfo));
    }

    /**
     * 修改产品联登结果信息
     */
    @PreAuthorize("@ss.hasPermi('product:productUnion:edit')")
    @Log(title = "产品联登结果信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductUnionResultInfo productUnionResultInfo)
    {
        return toAjax(productUnionResultInfoService.updateProductUnionResultInfo(productUnionResultInfo));
    }

    /**
     * 删除产品联登结果信息
     */
    @PreAuthorize("@ss.hasPermi('product:productUnion:remove')")
    @Log(title = "产品联登结果信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(productUnionResultInfoService.deleteProductUnionResultInfoByIds(ids));
    }

    @GetMapping("/extData")
    public AjaxResult extData()
    {
        JSONObject returnData = new JSONObject();
        returnData.put("statusList", UnionStatusEnum.getMapList());
        return AjaxResult.success(returnData);
    }
}
